package b.g.b.h.l;

import java.util.ArrayList;

/* compiled from: RunGroup */
public class l {
    public static int c;
    public o a = null;
    public ArrayList<o> b = new ArrayList();

    public l(o oVar, int i) {
        c++;
        this.a = oVar;
    }

    public final long a(f fVar, long j) {
        o oVar = fVar.d;
        if (oVar instanceof j) {
            return j;
        }
        int size = fVar.k.size();
        long j2 = j;
        for (int i = 0; i < size; i++) {
            d dVar = (d) fVar.k.get(i);
            if (dVar instanceof f) {
                f fVar2 = (f) dVar;
                if (fVar2.d != oVar) {
                    j2 = Math.min(j2, a(fVar2, ((long) fVar2.f) + j));
                }
            }
        }
        if (fVar == oVar.i) {
            j -= oVar.j();
            j2 = Math.min(Math.min(j2, a(oVar.h, j)), j - ((long) oVar.h.f));
        }
        return j2;
    }

    public final long b(f fVar, long j) {
        o oVar = fVar.d;
        if (oVar instanceof j) {
            return j;
        }
        int size = fVar.k.size();
        long j2 = j;
        for (int i = 0; i < size; i++) {
            d dVar = (d) fVar.k.get(i);
            if (dVar instanceof f) {
                f fVar2 = (f) dVar;
                if (fVar2.d != oVar) {
                    j2 = Math.max(j2, b(fVar2, ((long) fVar2.f) + j));
                }
            }
        }
        if (fVar == oVar.h) {
            j += oVar.j();
            j2 = Math.max(Math.max(j2, b(oVar.i, j)), j - ((long) oVar.i.f));
        }
        return j2;
    }
}
